<HTML>
<HEAD>
   <TITLE>ENUM keyword</TITLE>
</HEAD>

<BODY BGCOLOR="#DDDDDD">

<HR>
<CENTER>
<H1>
<FONT COLOR="#A52A2A">C++ changes to ENUM.</FONT>
</H1>
</CENTER>

<HR>

<P><FONT COLOR="#A52A2A">In the C++ world, the rules applying to 
<B>enum</B> have been altered.

<ul>
<li>Definitions no longer require the enum prefix or a 
<a href=../../C/SYNTAX/typedef.html>typedef</a> fudge.
</ul>
<CENTER><TABLE BORDER=0 COLS=1 WIDTH="80%" BGCOLOR="ivory" >
<TR>
<TD>
<pre>

    main ()
    {
        enum Currancy = {STERLING, DOLLAR, RUPEE};
                                                                
        enum Currancy GreenBack = DOLLAR;     // Valid in C and C++
        Currancy Pounds = STERLING;           // Valid in C++ only.

    }
</pre>
</TD>
</TR>
</TABLE></CENTER>



<UL>
<LI>
<FONT COLOR="#A52A2A">An <B>enum</B> is no longer considered to be an int
datatype. Because it has its own datatype you can not perform normal arithmatic
apon <B>enum</B> variables. The following program is now invalid.</FONT></LI>
</UL>
<CENTER><TABLE BORDER=0 COLS=1 WIDTH="80%" BGCOLOR="ivory" >
<TR>
<TD>
<pre>

    main ()
    {
        enum Currancy = {STERLING, DOLLAR, RUPEE};

        Currancy Pounds = STERLING;

        Pounds = 2;             // Invalid Statement.

        Pounds++;               // Invalid Statement.
    }
</pre>
</TD>
</TR>
</TABLE></CENTER>

<P>
<HR>
<H2>
<FONT COLOR="#A52A2A">Examples:</FONT></H2>
<IMG SRC="computer.gif" ALT="o" ><FONT COLOR="#A52A2A"> <A HREF="../EXAMPLES/enum1.cc">Example
program.</A>&nbsp;</FONT>&nbsp;
<HR>
<H2>
<FONT COLOR="#A52A2A">See Also:</FONT></H2>

<HR>
<H2>
<FONT COLOR="#000000">C References</FONT></H2>
<IMG SRC="whiteball.gif" ALT="o" ><FONT COLOR="#000000"> <A HREF="../../C/SYNTAX/enum.html">C
version of <B>enum</B>.</A></FONT>

<P>
<hr>
<center>
<table border=2 width="80%" bgcolor="ivory">
<tr align=center>
<td width="25%">
<a href="cref.html">Top</a>
</td><td width="25%">
<a href="../../C/master_index.html">Master Index</a>
</td><td width="25%">
<a href="keywords.html">C++ Keywords</a>
</td><td width="25%">
<a href="../../C/FUNCTIONS/funcref.htm">Functions</a>
</td>
</tr>
</table>
</center>
<p>
<hr>
<font color=brown>
<address><a href="../../address.html">Martin Leslie</a> 
25-Oct-98</address><p>

</BODY>
</HTML>
